package com.itheima.controller;

import com.itheima.pojo.JobOption;
import com.itheima.pojo.PersonCountOption;
import com.itheima.result.Result;
import com.itheima.service.ReportService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/report")
@Slf4j
@RequiredArgsConstructor
public class ReportController {

    @Autowired
    private ReportService reportService;

    /**
     * 员工职位人数统计
     * @return
     */
    @GetMapping("/empJobData")
    public Result empJobData(){
        JobOption jobOption = reportService.empJobData();
        return Result.success(jobOption);
    }

    /**
     * 员工性别人数统计
     */
    @GetMapping("empGenderData")
    public Result empGenderData(){
        List<Map<String,Object>> dataList = reportService.empGenderData();
        return Result.success(dataList);
    }
    /**
     * 学员学历人数统计
     */
    @GetMapping("/studentDegreeData")
    public Result getStudentDegreeData(){
        log.info("统计各个学历的学员人数");
        List<Map<String,Object>> degreeList = reportService.countStudentDegreeData();
        return Result.success(degreeList);
    }

    /**
     *班级人数统计
     */
    @GetMapping("/studentCountData")
    public Result getClazzData(){
        log.info("统计各个班级的学员人数");
        PersonCountOption personCountOption = reportService.countClazzData();
        return Result.success(personCountOption);
    }
}
